<template>
    <div>
        <div class="header">
            <van-nav-bar title="影院" @click-left="onClickLeft" @click-right="onClickRight">
                <template #left>
                    {{ store.state.city.name }}&nbsp;&nbsp;<img
                        src=""
                        alt="" style="width: 6px; height: 3px;">
                </template>
                <template #right>
                    <van-icon name="search" size="20" />
                </template>
            </van-nav-bar>
        </div>
        <div class="top">
            <van-dropdown-menu>
                <van-dropdown-item v-model="value1" :options="option1" />
                <van-dropdown-item v-model="value2" :options="option2" />
                <van-dropdown-item v-model="value3" :options="option3" />
            </van-dropdown-menu>
        </div>
        <div class="cinemas">
            <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
                <div class="li" v-for="cinema in cinemas.data" :key="cinema.cinemaId" @click="toFilm(cinema.cinemaId)">
                    <a href="javascript:;">
                        <div class="cinemaLeft">
                            <span class="cinemaName">
                                {{ cinema.name }}
                            </span>
                            <span class="cinemaAddress">
                                {{ cinema.address }}
                            </span>
                        </div>
                        <div class="cinemaRight">
                            <div class="cinemaPrice">
                                <span class="number">￥{{ cinema.lowPrice / 100 }}</span>
                                <span class="more">起</span>
                            </div>
                            <span class="gps">距离未知</span>
                        </div>
                    </a>
                </div>
            </van-list>
        </div>
    </div>
</template>

<script setup>
import store from '@/store'
import { useRouter, useRoute } from 'vue-router'

// import Vue from 'vue';
import { NavBar } from 'vant';
import { cinema } from '@/request/request'
import { DropdownMenu, DropdownItem } from 'vant';
import { Icon } from 'vant';
import { Cell, CellGroup } from 'vant';
import { List } from 'vant';

import { createApp, reactive,ref } from 'vue';
const app = createApp();

const router = useRouter()
const route = useRoute()

app.use(List);
app.use(Cell);
app.use(CellGroup);
app.use(Icon);
app.use(DropdownMenu);
app.use(DropdownItem);
app.use(NavBar);



let loading = ref(false)
let finished = ref(false)
let page =ref(1)
let total = ref(0)
let cinemas = reactive({
    data: []
})
let value1 = ref(0)
let value2 = ref('a')
let value3 = ref('A')
let option1 = reactive([
    { text: '全城', value: 0 },
    { text: '新款商品', value: 1 },
    { text: '活动商品', value: 2 },
])
let option2 = reactive([
    { text: 'APP订票', value: 'a' },
    { text: '前台兑换', value: 'b' },
])
let option3 = reactive([
    { text: '最近去过', value: 'A' },
    { text: '离我最近', value: 'B' },
])
let onClickLeft = () => {
    router.push('/city')
}
let onClickRight = () => {

}
let toFilm = (id) => {
    router.push({ path: 'film', query: { cinemaId: id } })
}
let city = store.state.city
let onLoad = () => {
    cinema(page, city.cityId).then(res => {
        cinemas.data = [...cinemas.data, ...res.cinemas]
        total = res.total
        if (Math.ceil(total / 10) > page) {
            page++
        } else {
            finished = true
        }
        loading = false
    });
}

</script>

<style lang="scss" scoped>
.custom-title {
    margin-right: 4px;
    vertical-align: middle;
}

.search-icon {
    font-size: 16px;
    line-height: inherit;
}

.cinemas {
    position: relative;
    background-color: #fff;
    padding: 15px;
    list-style: none;

    // li:after {
    //     content: " ";
    //     position: absolute;
    //     left: 0;
    //     bottom: 0;
    //     right: 0;
    //     height: 1px;
    //     border-bottom: 1px solid #ededed;
    //     color: #ededed;
    //     -webkit-transform-origin: 0 100%;
    //     -ms-transform-origin: 0 100%;
    //     transform-origin: 0 100%;
    //     -webkit-transform: scaleY(.5);
    //     -ms-transform: scaleY(.5);
    //     transform: scaleY(.5);
    // }

    .li {
        position: relative;
        background-color: #fff;
        padding: 15px;
        list-style: none;

        a {
            width: 100%;
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-pack: start;
            -ms-flex-pack: start;
            justify-content: flex-start;
            -webkit-box-align: center;
            -ms-flex-align: center;
            align-items: center;
            color: #333;
            text-decoration: none;

            .cinemaLeft {
                width: calc(100% - 65px);
                text-align: left;
                padding-right: 15px;
                float: left;

                .cinemaName {
                    color: #191a1b;
                    font-size: 15px;
                    float: left;
                    display: block;
                    max-width: 80%;
                    overflow: hidden;
                    -o-text-overflow: ellipsis;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                }

                span.cinemaAddress {
                    color: #797d82;
                    font-size: 12px;
                    margin-top: 5px； display：block;
                    max-width: 80%;
                    overflow: hidden;
                    -o-text-overflow: ellipsis;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    float: left;
                }
            }

            div.cinemaRight {
                width: 70px;
                text-align: center;
                float: right;
                margin-right: -5px;

                .number {
                    float: none !important;
                    font-size: 14px;
                    color: #ff5f16;
                    height: 0 !important;
                    display: inline-table !important;
                }

                .more {
                    color: #ff5f16;
                    font-size: 10px;
                }

                .gps {
                    display: block;
                    font-size: 11px;
                    color: #797d82;
                    margin-top: 5px;
                }
            }
        }
    }
}
</style>
